package com.xcl.mapper;

import com.xcl.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {

    //查询所有的文章分类
    @Select("select * from category")
    public List<Category> findAll();


    //根据id删除分类
    @Delete("delete from category where id = #{id}")
    public Integer deleteById(Integer id);


    //增加分类
    @Insert("insert into category (category_name, category_alias, create_user, create_time, update_time) " +
            "values (#{categoryName},#{categoryAlias},#{createUser},now(),now()) ")
    public Integer addCategory(Category category);


    //编辑数据
    @Update("update category set category_name = #{categoryName}," +
            " category_alias = #{categoryAlias}," +
            " create_user = #{createUser}," +
            " update_time = now() " +
            " where id=#{id}")
    public Integer update(Category category);

}
